var path=require('path')

var Wechat=require('../wechat/wechat')

var utils=require('../libs/util')
var wechat_file=path.join(__dirname,'../config/wechat.txt')
var wechat_ticket_file=path.join(__dirname,'../config/wechat_ticket.txt')

var config = {
    wechat:{
        appID:'wx2745a755607f5c52',
        appSecret:'b699b6fc290e0d9de85fa9f3bc31e0eb',
        token:'h6Mrie6Gar8Y7wNufGysxFDvx1MBmvyV',
        getAccessToken:function(){
            return utils.readFileAsync(wechat_file)
        },
        saveAccessToken:function(data){
            data=JSON.stringify(data)
            return utils.writeFileAsync(wechat_file,data)
        },
        getTicket:function(){
            return utils.readFileAsync(wechat_ticket_file)
        },
        saveTicket:function(data){
            data=JSON.stringify(data)
            return utils.writeFileAsync(wechat_ticket_file,data)
        },
    }
}


exports.getWechat=function(){
    var wechatApi=new Wechat(config.wechat)

    return wechatApi
}

exports.config=config
